---
hide_table_of_contents: true
sidebar_position: 3
---

import CodeBlock from "@theme/CodeBlock";

import Example from "!!raw-loader!@examples/agents/chat_convo_with_tracing.ts";


# 会话代理

本示例介绍如何为聊天模型创建会话代理。它将利用聊天特定的提示。

<CodeBlock language="typescript">{Example}</CodeBlock>


````
Loaded agent.

Entering new agent_executor chain...

{

    "action": "Final Answer",

    "action_input": "Hello Bob! How can I assist you today?"

}

Finished chain.

Got output Hello Bob! How can I assist you today?

Entering new agent_executor chain...

{

    "action": "Final Answer",

    "action_input": "Your name is Bob."

}

Finished chain.

Got output Your name is Bob.

Entering new agent_executor chain...

```json

{
    "action": "search",

    "action_input": "weather in pomfret"

}
```
A steady rain early...then remaining cloudy with a few showers. High 48F. Winds WNW at 10 to 15 mph. Chance of rain 80%.

```json

{
    "action": "Final Answer",

    "action_input": "The weather in Pomfret is a steady rain early...then remaining cloudy with a few showers. High 48F. Winds WNW at 10 to 15 mph. Chance of rain 80%."

}
```

Finished chain.

Got output The weather in Pomfret is a steady rain early...then remaining cloudy with a few showers. High 48F. Winds WNW at 10 to 15 mph. Chance of rain 80%.

````

